package org.gap.web.jsf;

import java.util.List;

import org.gap.dao.RelationsDAO;
import org.gap.dao.RelationsTiersDAO;
import org.gap.dao.TiersDAO;

import org.gap.domain.Relations;
import org.gap.domain.RelationsTiers;
import org.gap.domain.Tiers;

import org.gap.service.RelationsTiersService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

import org.springframework.transaction.annotation.Transactional;

/**
 * Spring Component that handles CRUD requests for RelationsTiers entities
 * 
 */
@Scope("session")
@Component("RelationsTiersComponent")
public class RelationsTiersComponentImpl implements RelationsTiersComponent {

	/**
	 * Data type variable that provides CRUD operations for RelationsTiers entities
	 * 
	 */
	private RelationsTiers relationstiers;

	/**
	 * DAO injected by Spring that manages Tiers entities
	 * 
	 */
	private Tiers tiersbyrlttiersfils;

	/**
	 * DAO injected by Spring that manages Relations entities
	 * 
	 */
	private Relations relations;

	/**
	 * DAO injected by Spring that manages Tiers entities
	 * 
	 */
	private Tiers tiersbyrlttiersparent;

	/**
	 * DAO injected by Spring that manages Relations entities
	 * 
	 */
	@Autowired
	private RelationsDAO relationsDAO;

	/**
	 * DAO injected by Spring that manages RelationsTiers entities
	 * 
	 */
	@Autowired
	private RelationsTiersDAO relationsTiersDAO;

	/**
	 * DAO injected by Spring that manages Tiers entities
	 * 
	 */
	@Autowired
	private TiersDAO tiersDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for RelationsTiers entities
	 * 
	 */
	@Autowired
	private RelationsTiersService relationsTiersService;

	/** 
	 */
	public RelationsTiersComponentImpl() {
	}

	/**
	 * Select the child Relations entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, String related_relations_relRelation) {
		relations = relationsDAO.findRelationsByPrimaryKey(related_relations_relRelation);

		return "/jsf/relationstiers/relations/deleteRelations.xhtml";
	}

	/**
	 * Getter for variable RelationsTiers
	 * 
	 */
	@Transactional
	public Tiers getTiersbyrlttiersparent() {
		return tiersbyrlttiersparent;
	}

	/**
	 * Delete an existing Tiers entity
	 * 
	 */
	@Transactional
	public String deleteRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersparent_tieTiers) {
		relationstiers = relationsTiersService.deleteRelationsTiersTiersByRltTiersParent(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, related_tiersbyrlttiersparent_tieTiers);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Delete an existing RelationsTiers entity
	 * 
	 */
	@Transactional
	public String deleteRelationsTiers(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		RelationsTiers relationstiers = relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey);
		relationsTiersService.deleteRelationsTiers(relationstiers);
		return "/jsf/relationstiers/listRelationsTierss.xhtml";
	}

	/**
	 * View an existing Tiers entity
	 * 
	 */
	@Transactional
	public String selectRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersparent_tieTiers) {
		tiersbyrlttiersparent = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersparent_tieTiers, -1, -1);
		return "/jsf/relationstiers/tiersbyrlttiersparent/viewTiersByRltTiersParent.xhtml";
	}

	/**
	 * Getter for variable RelationsTiers
	 * 
	 */
	@Transactional
	public Tiers getTiersbyrlttiersfils() {
		return tiersbyrlttiersfils;
	}

	/**
	 * Save an existing Tiers entity
	 * 
	 */
	@Transactional
	public String saveRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Tiers tiers) {
		relationstiers = relationsTiersService.saveRelationsTiersTiersByRltTiersParent(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, tiers);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Edit an existing Tiers entity
	 * 
	 */
	@Transactional
	public String editRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersfils_tieTiers) {
		tiersbyrlttiersfils = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersfils_tieTiers, -1, -1);
		return "/jsf/relationstiers/tiersbyrlttiersfils/editTiersByRltTiersFils.xhtml";
	}

	/**
	 * Select an existing RelationsTiers entity
	 * 
	 */
	@Transactional
	public String selectRelationsTiers(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		relationstiers = relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Create a new RelationsTiers entity
	 * 
	 */
	@Transactional
	public String newRelationsTiers() {
		relationstiers = new RelationsTiers();

		return "/jsf/relationstiers/createRelationsTiers.xhtml";
	}

	/**
	 * Save an existing Relations entity
	 * 
	 */
	@Transactional
	public String saveRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Relations relations) {
		relationstiers = relationsTiersService.saveRelationsTiersRelations(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, relations);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Select the child Tiers entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersfils_tieTiers) {
		tiersbyrlttiersfils = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersfils_tieTiers);

		return "/jsf/relationstiers/tiersbyrlttiersfils/deleteTiersByRltTiersFils.xhtml";
	}

	/**
	 * Get Tiers entity by RelationsTiers
	 * 
	 */
	@Transactional
	public Tiers getRelationsTiersTiersByRltTiersParent(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		return relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey).getTiersByRltTiersParent();
	}

	/**
	 * Getter for variable RelationsTiers
	 * 
	 */
	@Transactional
	public RelationsTiers getRelationstiers() {
		return relationstiers;
	}

	/**
	 * Delete an existing Relations entity
	 * 
	 */
	@Transactional
	public String deleteRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, String related_relations_relRelation) {
		relationstiers = relationsTiersService.deleteRelationsTiersRelations(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, related_relations_relRelation);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Select the child Tiers entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersparent_tieTiers) {
		tiersbyrlttiersparent = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersparent_tieTiers);

		return "/jsf/relationstiers/tiersbyrlttiersparent/deleteTiersByRltTiersParent.xhtml";
	}

	/**
	 * Edit an existing Relations entity
	 * 
	 */
	@Transactional
	public String editRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, String related_relations_relRelation) {
		relations = relationsDAO.findRelationsByPrimaryKey(related_relations_relRelation, -1, -1);
		return "/jsf/relationstiers/relations/editRelations.xhtml";
	}

	/**
	 * Getter for variable RelationsTiers
	 * 
	 */
	@Transactional
	public Relations getRelations() {
		return relations;
	}

	/**
	 * Save an existing Tiers entity
	 * 
	 */
	@Transactional
	public String saveRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Tiers tiers) {
		relationstiers = relationsTiersService.saveRelationsTiersTiersByRltTiersFils(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, tiers);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Delete an existing Tiers entity
	 * 
	 */
	@Transactional
	public String deleteRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersfils_tieTiers) {
		relationstiers = relationsTiersService.deleteRelationsTiersTiersByRltTiersFils(relationstiers_rltTiersParent, relationstiers_rltTiersFils, relationstiers_rltRelation, related_tiersbyrlttiersfils_tieTiers);

		return "/jsf/relationstiers/viewRelationsTiers.xhtml";
	}

	/**
	 * Create a new Tiers entity
	 * 
	 */
	@Transactional
	public String newRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation) {
		tiersbyrlttiersfils = new Tiers();

		return "/jsf/relationstiers/tiersbyrlttiersfils/createTiersByRltTiersFils.xhtml";
	}

	/**
	 * Show all RelationsTiers entities
	 * 
	 */
	@Transactional
	public List<RelationsTiers> listRelationsTierss() {
		return new java.util.ArrayList<RelationsTiers>(relationsTiersService.loadRelationsTierss());
	}

	/**
	 * Select the RelationsTiers entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeleteRelationsTiers(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		relationstiers = relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey);

		return "/jsf/relationstiers/deleteRelationsTiers.xhtml";
	}

	/**
	 * Create a new Relations entity
	 * 
	 */
	@Transactional
	public String newRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation) {
		relations = new Relations();

		return "/jsf/relationstiers/relations/createRelations.xhtml";
	}

	/**
	 * View an existing Tiers entity
	 * 
	 */
	@Transactional
	public String selectRelationsTiersTiersByRltTiersFils(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersfils_tieTiers) {
		tiersbyrlttiersfils = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersfils_tieTiers, -1, -1);
		return "/jsf/relationstiers/tiersbyrlttiersfils/viewTiersByRltTiersFils.xhtml";
	}

	/**
	 * View an existing Relations entity
	 * 
	 */
	@Transactional
	public String selectRelationsTiersRelations(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, String related_relations_relRelation) {
		relations = relationsDAO.findRelationsByPrimaryKey(related_relations_relRelation, -1, -1);
		return "/jsf/relationstiers/relations/viewRelations.xhtml";
	}

	/**
	 * Save an existing RelationsTiers entity
	 * 
	 */
	@Transactional
	public String saveRelationsTiers(RelationsTiers relationstiers) {
		relationsTiersService.saveRelationsTiers(relationstiers);
		return "/jsf/relationstiers/listRelationsTierss.xhtml";
	}

	/**
	 * Get Tiers entity by RelationsTiers
	 * 
	 */
	@Transactional
	public Tiers getRelationsTiersTiersByRltTiersFils(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		return relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey).getTiersByRltTiersFils();
	}

	/**
	 * Get Relations entity by RelationsTiers
	 * 
	 */
	@Transactional
	public Relations getRelationsTiersRelations(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		return relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey).getRelations();
	}

	/**
	 * Edit an existing RelationsTiers entity
	 * 
	 */
	@Transactional
	public String editRelationsTiers(Integer rltTiersParentKey, Integer rltTiersFilsKey, String rltRelationKey) {
		relationstiers = relationsTiersDAO.findRelationsTiersByPrimaryKey(rltTiersParentKey, rltTiersFilsKey, rltRelationKey);

		return "/jsf/relationstiers/editRelationsTiers.xhtml";
	}

	/**
	 * Edit an existing Tiers entity
	 * 
	 */
	@Transactional
	public String editRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation, Integer related_tiersbyrlttiersparent_tieTiers) {
		tiersbyrlttiersparent = tiersDAO.findTiersByPrimaryKey(related_tiersbyrlttiersparent_tieTiers, -1, -1);
		return "/jsf/relationstiers/tiersbyrlttiersparent/editTiersByRltTiersParent.xhtml";
	}

	/**
	 * Create a new Tiers entity
	 * 
	 */
	@Transactional
	public String newRelationsTiersTiersByRltTiersParent(Integer relationstiers_rltTiersParent, Integer relationstiers_rltTiersFils, String relationstiers_rltRelation) {
		tiersbyrlttiersparent = new Tiers();

		return "/jsf/relationstiers/tiersbyrlttiersparent/createTiersByRltTiersParent.xhtml";
	}

}
